package mousemove;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;

public class Robot extends Sprite
{
	private Random random;
	private int frameWidth, frameHeight;
	
	public Robot(int x, int y, int v)
	{
		super(x>>2, y>>2, v);
		frameWidth = x;
		frameHeight = y;
		color = Color.LIGHT_GRAY;
		width = 5;
		height = 5;
		random = new Random();
		setDest();
	}

	private void setDest()
	{
		super.setDestination(random.nextInt(frameWidth), random.nextInt(frameHeight));
		isMoving = true;
	}
	
	public void move()
	{
		if (super.arrived())
		{
			setDest();
		}
		else
		{
			currentX += increX;
			currentY += increY;
		}
	}
	
	@Override
	public void draw(Graphics g)
	{
		g.setColor(color);
		g.fillOval((int)currentX, (int)currentY, width, height);
	}
}
